package cn.bluethink.eguan.core.entity;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;

import cn.bluethink.eguan.model.core.EgAcount;
import cn.bluethink.eguan.model.core.EgCheckStatus;
import cn.bluethink.eguan.model.core.EgFaction;
import cn.bluethink.eguan.model.core.EgUser;

/**
 * 门派实体模型
 * 
 * @author 苏州中科蓝迪公司所有(c)2016-2021
 * @version 0.2.0
 * @brief 驿馆+（EGUAN）
 * @note 修订历史： 1、wanglei于2018/11/09修订
 */
@Table(name = "eg_faction")
public class EgFactionEntity implements Serializable {

    private static final long serialVersionUID = 2251229073629034681L;

    @Id
    // 门派唯一标识
    private Long fid;

    // 外部系统团队账号
    private String f_id;

    // 门派名称
    private String name;

    // 门派图标
    private String icon;

    // 门派账户标识
    private Long acount;

    // 门派季度年的起始月份
    private Integer bmonth;

    // 门派创建者
    private Long uid;

    /**
     * 禅道服务地址
     */
    @Column(name = "zt_server_address")
    private String ztServerAddress;

    private Date ctime;

    private Date utime;

    @Column(name = "check_status")
    private Integer checkStatus;

    public EgFactionEntity() {

    }

    /**
     * 业务模型转实体模型
     * 
     * @param faction
     * @param f_id
     */
    public EgFactionEntity(EgFaction faction, String f_id) {
        this.fid = faction.getId();
        this.f_id = f_id;
        this.name = faction.getName();
        this.icon = faction.getIcon();
        this.acount = faction.getAcount() == null ? null : faction.getAcount().getId();
        // 默认季度年的开始月份为1月份
        this.bmonth = faction.getBmonth() == null ? 1 : faction.getBmonth();
        this.uid = faction.getUser() == null ? null : faction.getUser().getId();
        this.checkStatus = faction.getCheckStatus() == null ? EgCheckStatus.STATUS_PENDING : faction.getCheckStatus();
    }

    /**
     * 将实体模型转为业务模型
     * 
     * @return
     */
    public EgFaction createFaction() {
        EgFaction faction = new EgFaction(fid, name, icon);
        faction.setAcount(new EgAcount(acount, null, null));
        faction.setBmonth(bmonth);
        faction.setUser(new EgUser(uid, null, null));
        faction.setuTime(utime);
        faction.setCheckStatus(checkStatus);
        return faction;
    }

    public Long getFid() {
        return fid;
    }

    public void setFid(Long fid) {
        this.fid = fid;
    }

    public String getF_id() {
        return f_id;
    }

    public void setF_id(String f_id) {
        this.f_id = f_id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
        this.icon = icon;
    }

    public Long getAcount() {
        return acount;
    }

    public void setAcount(Long acount) {
        this.acount = acount;
    }

    public Integer getBmonth() {
        return bmonth;
    }

    public void setBmonth(Integer bmonth) {
        this.bmonth = bmonth;
    }

    public Long getUid() {
        return uid;
    }

    public void setUid(Long uid) {
        this.uid = uid;
    }

    public Date getCtime() {
        return ctime;
    }

    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }

    public Date getUtime() {
        return utime;
    }

    public void setUtime(Date utime) {
        this.utime = utime;
    }

    public Integer getCheckStatus() {
        return checkStatus;
    }

    public void setCheckStatus(Integer checkStatus) {
        this.checkStatus = checkStatus;
    }

    public String getZtServerAddress() {
        return ztServerAddress;
    }

    public void setZtServerAddress(String ztServerAddress) {
        this.ztServerAddress = ztServerAddress;
    }

}
